import Vue from 'vue';
import App from './App.vue';
import ElementUI from 'element-ui';
import { bootstrap } from '@/cool/core';

import router from '@/router';
import routes from '@/router/routes/views';
import store from '@/store';

import '@/mock';
import '@/icons/index';
import '@/filter/index';
import '@/assets/css/element-variables.scss';

Vue.use(ElementUI);

Vue.config.productionTip = false;

const conf = {
	store,
	router,
	['view-routes']: routes,
	['cl-crud']: {
		crud: {
			table: {
				props: {
					stripe: true
				},
				scopedSlots: {
					// eslint-disable-next-line
					empty: ({ h }) => {
						return (
							<div style="padding:40px 0">
								<icon-svg
									style="width:100px;height:100px"
									name="icon-empty"></icon-svg>
								<div style="line-height:20px;margin-top: -10px;">暂无数据</div>
							</div>
						);
					}
				}
			},
			dict: {
				sort: {
					prop: 'order',
					order: 'sort'
				}
			},
			fn: {
				permission(that) {
					const { permission } = that.$store.state.menu;
					const { add, delete: del, update } = that.service.permission || {};

					return {
						add: permission.includes(add),
						delete: permission.includes(del),
						update: permission.includes(update)
					};
				}
			}
		}
	}
};

bootstrap(conf).then(({ router, store }) => {
	store.dispatch('appLoad');

	new Vue({
		router,
		store,
		render: h => h(App)
	}).$mount('#app');
});
